#ifndef _SCIENCE_MATHEMATICS_ALGEBRA_CARTESIAN_PLANE_H_
#define _SCIENCE_MATHEMATICS_ALGEBRA_CARTESIAN_PLANE_H_
//-----------------------------------------------------------------------------------------------------//
//																	                                   //
// number_line.h  contains definitions of the number line type and the                                 //
// functions needed to draw it and process its contents.					                           //
//																									   //
// author	: Eng. Ahmed Yasser																		   //
// data		: 21-01-2015																			   //
//																	                                   //
//-----------------------------------------------------------------------------------------------------//

#include <vector>

#include "..\..\..\common\include\opengl_draws.h"
#include "..\include\ordered_pair.h"

//-----------------------------------------------------------------------------------------------------//
//																									   //
// the structures that define the cartesian plane													   //
//																									   //
//-----------------------------------------------------------------------------------------------------//

// the drawing info of the cartesian plane
struct cartesian_plane_draw_info_t
{
	float sx;			// the starting point of the x-axis
	float sy;			// the starting point of the y-axis
	float ex;			// the ending point of the x-axis
	float ey;			// the ending point of the y-axis
	float length_x;	// the length of the line in the x axis		
	float length_y;	// the length of the line in the y axis
};

// the cartesian plane type
struct cartesian_plane_t
{
	float origin_x;		// the origin x of the cartesian plane
	float origin_y;		// the origin y of the cartesian plane
	float step_x;			// the step value in x_axis
	float step_y;			// the step value in y_axis
	unsigned int length_x;	// the number of steps in each side of the x_axis
	unsigned int length_y;	// the number of steps in each side of the y_axis
	cartesian_plane_draw_info_t draw_info;	// the draw info of the cartesian plane
};

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// name		: create_cartesian_plane																   //
//																									   //
// desc		: create a cartesian plane												                   //
//																									   //
// params	:																						   //
//		float x	: the origin x of the cartesian plane											   //
//		float y	: the origin y of the cartesian plane											   //
//		float sx	: the step value in x_axis														   //
//		float sy	: the step value in y_axis														   //
//		unsigned int lx	: the number of steps in each side of the x_axis							   //
//		unsigned int ly	: the number of steps in each side of the y_axis							   //
// returns	: the created cartesian plane															   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////
cartesian_plane_t create_cartesian_plane(float x, float y, float sx, float sy, unsigned int lx, unsigned int ly);

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// name		: transform_to_cartesian_plane															   //
//																									   //
// desc		: transforms the world of opengl to fit in this cartesian plane			                   //
//																									   //
// params	:																						   //
//		const cartesian_plane_t& cp	: the cartesian plane to transform to							   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void transform_to_cartesian_plane(const cartesian_plane_t& cp);

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// name		: draw_cartesian_plane																       //
//																									   //
// desc		: draws a cartesian plane												                   //
//																									   //
// params	:																						   //
//		const cartesian_plane_t& cp	: the cartesian plane to draw									   //
//		float r	: the red color of the cartesian plane											   //
//		float g	: the green color of the cartesian plane										   //
//		float b	: the blue color of the cartesian plane											   //
//		float a	: the alpha color of the cartesian plane										   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void draw_cartesian_plane(const cartesian_plane_t& cp, float r, float g, float b, float a);

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// name		: draw_ordered_pair																           //
//																									   //
// desc		: draws an ordered pair on a cartesian plane										       //
//																									   //
// params	:																						   //
//		ordered_pair pair	: the ordered pair to draw												   //
//		const cartesian_plane_t& cp	: the cartesian plane to draw pair on it					       //
//		float r	: the red color of the number													   //
//		float g	: the green color of the number													   //
//		float b	: the blue color of the number												       //
//		float a	: the alpha color of the number												       //
//		bool dis_info : if display the pair info or not												   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void draw_ordered_pair(ordered_pair pair, const cartesian_plane_t& cp, float r, float g, float b, float a, bool dis_info = false);

/////////////////////////////////////////////////////////////////////////////////////////////////////////
// name		: draw_ordered_pairs															           //
//																									   //
// desc		: draws a list of ordered pairs on a cartesian plane								       //
//																									   //
// params	:																						   //
//		std::vector<ordered_pair> pairs	: the list of ordered pairs to draw							   //
//		const cartesian_plane_t& cp	: the cartesian plane to draw pair on it					       //
//		float r	: the red color of the number													   //
//		float g	: the green color of the number													   //
//		float b	: the blue color of the number												       //
//		float a	: the alpha color of the number												       //
//		bool dis_info : if display the pair info or not												   //
//		bool connect : if connect the dots or not													   //
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void draw_ordered_pairs(std::vector<ordered_pair> pairs, const cartesian_plane_t& cp, float r, float g, float b, float a, bool dis_info = false, bool connect = true);

#endif